import { CommonFieldType } from './types'
import { inject } from 'vue'

export const SchemaFormContextKey = Symbol()

export function useSchemaFormContext() {
  const context: { SchemaItem: CommonFieldType } | undefined =
    inject(SchemaFormContextKey)

  if (!context) {
    throw Error()
  }

  return context
}
